﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Time.Model;

namespace Time.App
{
    public partial class AddEditModuleWindow : Form
    {
        public Module Module = null;
        public AddEditModuleWindow(Form owner)
        {
            this.Owner = owner;
            InitializeComponent();
        }

        private void txtName_TextChanged(object sender, EventArgs e)
        {
            btnSave.Enabled = txtName.Text.Length > 0;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Module = new Module { Name = txtName.Text };

            if (Module.PublicId == Guid.Empty)
                Module.PublicId = Guid.NewGuid();
            this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
